import { tabbarPages, pageMapper, entryPagePath } from "./constants/pageMap"

function getNormalPages(mapper: Recordable, holder = <string[]>[]) {
  Object.keys(mapper).forEach(key => {
    if (typeof mapper[key] === "string") {
      holder.push(mapper[key])
    } else {
      getNormalPages(mapper[key], holder)
    }
  })
  return holder
}

export default defineAppConfig({
  entryPagePath,
  pages: [
    ...Object.values(tabbarPages),
    ...getNormalPages(pageMapper)
  ],
  window: {
    backgroundTextStyle: 'dark',
    navigationBarBackgroundColor: '#fff',
    navigationBarTitleText: '智聘',
    navigationBarTextStyle: 'black'
  },
  usingComponents: {},
  sitemapLocation: "sitemap.json",
  requiredPrivateInfos: ["chooseLocation", "getFuzzyLocation"],
  permission: {
    "scope.userFuzzyLocation": {
      desc: "你的位置信息将用于小程序定位"
    }
  },
  tabBar: {
    borderStyle: "white",
    color: "#313337",
    selectedColor: "#0768FA",
    backgroundColor: "#FFFFFF",
    list: [
      {
        pagePath: tabbarPages.position,
        text: "职位",
        iconPath: '/static/icons/tabbar/position.png',
        selectedIconPath: '/static/icons/tabbar/position_selected.png'
      },
      {
        pagePath: tabbarPages.robot,
        text: "小智",
        iconPath: '/static/icons/tabbar/ai.png',
        selectedIconPath: '/static/icons/tabbar/ai_selected.png'
      },
      {
        pagePath: tabbarPages.chat,
        text: "聊天",
        iconPath: '/static/icons/tabbar/chat.png',
        selectedIconPath: '/static/icons/tabbar/chat_selected.png'
      },
      {
        pagePath: tabbarPages.me,
        text: "我的",
        iconPath: '/static/icons/tabbar/me.png',
        selectedIconPath: '/static/icons/tabbar/me_selected.png'
      }
    ]
  },
})
